#!/usr/bin/env bats

@test "filter no-around no-color case: 2 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11:6:Present is dejected here;"
  result="$(fish -c 'tbgs Present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case Present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Present no-color dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case Present dejected no-color')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Present case dejected no-color')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejected Present')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case dejected Present')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejected Present no-color')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case dejected no-color Present')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejected case Present no-color')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs Present dejEcTeD')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejected present')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dejEcTeD Present')"; [ "$result" = "$expected" ]
}

@test "filter no-around no-color case: 4 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11:4:Merry days will come, believe."
  result="$(fish -c 'tbgs Merry days will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case Merry days will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs days will come Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case days will come Merry')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs merry dAyS wIlL cOMe')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case merry dAyS wIlL cOMe')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dAyS wIlL cOMe merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case dAyS wIlL cOMe merry')"; [ "$result" = "$expected" ]
}

@test "filter no-around no-color case: 2 words partial match" {
  cd $BATS_TEST_DIRNAME
  expected="file11:6:Present is dejected here;"
  result="$(fish -c 'tbgs Pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case Pres dejec')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs case pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs pres dejEc')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case pres dejEc')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs case present dejEc')"; [ "$result" = "$expected" ]
}

@test "filter no-around no-color case: 2 words word only appears in file path" {
  cd $BATS_TEST_DIRNAME
  expected=""
  result="$(fish -c 'tbgs Present file')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs file dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs the file')"; [ "$result" = "$expected" ]
}
